﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using Sustainalytics.StorageSnapshot.BusinessLogic.Entities;
using Sustainalytics.StorageSnapshot.BusinessLogic;
using System.Threading;

namespace Sustainalytics.StorageSnapshot.Service
{
    static class StorageSnapshotHelper
    {
        static Timer snapshotTimer;
        static bool IsSnapshotInProgress = false;

        public static void Start()
        {
            if (snapshotTimer == null)
                snapshotTimer = new Timer(SnapshotTimer_Elapsed, null, 15000, 10000);
        }

        private static void SnapshotTimer_Elapsed(object timerState)
        {
            if (!IsSnapshotInProgress)
            {
                IsSnapshotInProgress = true;
                new SnapshotManagement().Start();
                IsSnapshotInProgress = false;
            }
        }
    }
}
